#include "MarsPrecompile.h"
#include "MarsCLContext.h"
#include "MarsCLMgr.h"
#include "MarsCLDevice.h"

using namespace GP;

bool CLContext::Create()
{
	MARS_ASSERT( CLMgr::Instance().GetCurrentPlatform() == m_device->GetPlatform() );

	cl_context_properties cps[ 3 ] = 
	{
		CL_CONTEXT_PLATFORM, 
		(cl_context_properties) CLMgr::Instance().GetCurrentPlatformId(), 
		0
	};

	cl_int status = CL_SUCCESS;
	m_context = clCreateContextFromType( cps, ( ( CLDevice* ) m_device.GetPointer() )->GetNativeDeviceType(), NULL, NULL, &status );
	if ( status != CL_SUCCESS )
	{
		// TODO: log error
		return false;
	}

	return true;
}